package com.cn.lb.rule;

import com.cn.lb.predicate.DefaultEnabledPredicate;
import com.netflix.loadbalancer.AbstractServerPredicate;
import com.netflix.loadbalancer.PredicateBasedRule;

/**
 * @author: chenyuncong
 * @Date: 2020/3/10 15:50
 */
public abstract class DefaultEnabledRule extends PredicateBasedRule {

    private final DefaultEnabledPredicate predicate;


    public DefaultEnabledRule(DefaultEnabledPredicate discoveryEnabledPredicate) {
//        this.predicate = createCompositePredicate(discoveryEnabledPredicate, new AvailabilityPredicate(this, null));
        this.predicate =discoveryEnabledPredicate;
    }
    //PredicateBasedRule父类choose()方法会触发predicate.chooseRoundRobinAfterFiltering()方法，
    //所以DefaultEnabledPredicate实现类需要从写chooseRoundRobinAfterFiltering()方法,可以在里面实现轮询，权重
    @Override
    public AbstractServerPredicate getPredicate() {
        return predicate;
    }


}
